﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ProjectSem3.admin
{
    public partial class WebForm13 : System.Web.UI.Page
    {
        private DataClasses1DataContext dc = new DataClasses1DataContext();
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void buttonRegistrar_Click(object sender, EventArgs e)
        {
            var user = dc.EmpRegisters.Where(aa => aa.username.Equals(this.username.Value)).ToList();
            if (user.Count > 0)
            {
                this.Labelketqua.Text = "Username already exists";

            }
            else
            {

                EmpRegister em = new EmpRegister();
                em.firstname = this.firstname.Value;
                em.lastname = this.lastname.Value;
                em.username = this.username.Value;
                em.password = this.Password.Value;
                em.joindate = DateTime.Now;
                em.salary = Convert.ToDecimal(this.salary.Value);
                em.city = this.city.Value;
                em.contactinfo = this.contactno.Value;
                em.country = this.country.Value;
                em.address = this.address.Value;
                dc.EmpRegisters.InsertOnSubmit(em);
                dc.SubmitChanges();
            }
        }
    }
}